Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Popupmenu add menuitem

30 views
Skip to first unread message

Co-Op

unread,
Jan 21, 2009, 7:40:26 AM1/21/09
to
this code adds an menu item ok. BUT it is still there the next time
the menu is called. How can I remove it each time the menu closes?

procedure TfmTankmix.PopupMenu1Popup(Sender: TObject);
var
menuItemProd1: TMenuItem;
menuItemProd2: TMenuItem;
menuItemActive: TMenuItem;
dset : TDataSet;
begin
dset := Dbgrid1.DataSource.DataSet ;
if (PopupMenu1.Items.Count> 2) then
menuItemProd1.Caption := dset.FieldByName('Product_names').Text
else if dset.FieldByName('Product_names').Text > '' then
begin
menuItemProd1 := TMenuItem.Create(PopupMenu1) ;
menuItemProd1.Caption := dset.FieldByName('Product_names').Text;
menuItemProd1.OnClick := PopupItemP1Click;
PopupMenu1.Items.Add(menuItemProd1) ;
end;
end;

procedure TfmTankmix.PopupItemP1Click(Sender: TObject) ;
var
menuItem : TMenuItem;
begin
if (Sender is TMenuItem) then begin
menuItem := TMenuItem(sender) ;
ShowMessage('Clicked on') ;
end;
end;

0 new messages